<? if ( ! defined('BASEPATH')) exit('No direct script access allowed');

function shortdate($day=''){
	if(empty($day)) return '';
	return strftime("%d.%m.%y", strtotime($day));
}
function dateus($day='')
{
	if(empty($day)) return '';
	return strftime("%d/%m/%Y", strtotime($day));
} 
function datemysql($day='')
{
	return strftime("%Y-%m-%d", strtotime($day));
} 
function datevn2mysql($day='')
{
	$data = explode("/", $day) ;
	return $data[2]."-".$data[1]."-".$data[0];
}
function datevn($day='', $dot='.')
{
	if(empty($day)) return '';
	return strftime("%d$dot%m$dot%Y", strtotime($day));
} 
function disdate($d1,$d2){
    //date yyyy-mm-dd
    $ar = explode("-",$d1) ;
    $br = explode("-",$d2) ;
   
    $a = mktime(0,0,0,intval($ar[1]),intval($ar[2]),intval($ar[0])) ;
    $b = mktime(0,0,0,intval($br[1]),intval($br[2]),intval($br[0])) ;
   
    $c = $b - $a ;
    $e = $c / (24 * 60 * 60) ;
   
    return $e ;
}
?>